package xuegao.study.mall.admin.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.admin.feign.AuthAppClient;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.oauth.OauthClientDetails;
import java.util.List;

@RequestMapping(value = "/auth/app")
@RestController
public class AuthAppController {

    @Autowired
    private AuthAppClient authAppClient;

    @ApiOperation("创建app")
    @PostMapping(value = "/create")
    public CommonResult create(@RequestBody OauthClientDetails details) {
        return authAppClient.create(details);
    }

    @PostMapping(value = "/delete/{clientId}")
    public CommonResult delete(@PathVariable String clientId) {
        return authAppClient.delete(clientId);
    }

    @ApiOperation("更新app")
    @PostMapping(value = "/update")
    public CommonResult update(@RequestBody OauthClientDetails details) {
        return authAppClient.update(details);
    }

    @ApiOperation("获取app列表")
    @GetMapping(value = "/list")
    public CommonResult<List<OauthClientDetails>> list() {
        return authAppClient.list();
    }
}
